<template>
  <div>
    <h2>当前计数: {{ counter }}</h2>
    <counter-operation
      @add="increment"
      @addN="incrementN"
      @sub="decrement"
    ></counter-operation>
  </div>
</template>

<script>
import CounterOperation from "./CounterOperation.vue";

export default {
  data() {
    return {
      counter: 0,
    };
  },
  components: { CounterOperation },
  methods: {
    increment() {
      this.counter++;
    },
    decrement() {
      this.counter--;
    },
    incrementN(num) {
      console.log(num);
      this.counter += num;
    },
  },
};
</script>

<style scoped></style>
